package com.yyq.adms.yyb.patent.bpo.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yyq.adms.util.JxlsVo;
import com.yyq.adms.yyb.patent.bpo.OwnPatentBpo;
import com.yyq.adms.yyb.patent.dao.OwnPatentDao;
import com.yyq.adms.yyb.patent.pojo.OwnPatent;
import com.yyq.sos.service.BaseBpoImpl;


/**
 * 获批专利 业务逻辑类
 * @author 杨应滨
 * @2012-12-3
 *
 */
@Service("ownPatentBpo")
@Transactional
public class OwnPatentBpoImpl  extends BaseBpoImpl implements OwnPatentBpo{

	private OwnPatentDao dao;

	@Resource(name="ownPatentDao")
	public void setDao(OwnPatentDao dao) {
		this.dao = dao;
		super.setBaseDao(dao);
	}

	public List validateUniquene(List<Map<String, JxlsVo>> data,
			StringBuffer errMsg) {
		Map<String,Integer> validate = new HashMap<String,Integer>();
		List otherData = new ArrayList();
		for (Map<String, JxlsVo> map : data) {
			String key = map.get("专利名称").getContent()+map.get("专利类型").getContent();
			if(validate.containsKey(key)){
				errMsg.append("第"+validate.get(key)+"行:(专利名称+专利类型)与第"+map.get("专利名称").getRow()+"行唯一性重复了\n");
			}else{
				validate.put(key, map.get("专利名称").getRow());
			}
		}
		return otherData;
	}
	
	public OwnPatent validateUniqueneDB(String name,String type){
		
		if("发明专利".equals(type)){
			type="1";
		}else if("实用新型专利".equals(type)){
			type="2";
		}else{
			System.out.println("输入的类型无效!"+type);
			return null;
		}
		String hql = "from OwnPatent where patentName='"+name+"' and patentType='";
		return null;
	}
}
